
clear 
set more off

use final_dataset.dta, clear 

*****************************************************************************************
* Table 2. Effects of P2 experience on GHG emission rates by difference-in-differences*
*****************************************************************************************
xtset oris_code time
reg d.lco2egen d.post_t d.p2flagXpt d.coald d.lnet_gen d.lauunem d.st_time d.oristime d.oristime2 d.oristime3 d.time d.time2 d.time3, vce(clus p2flagclus) nocons
reg d.lco2egen d.post_t d.hp2histXpt d.coald d.lnet_gen d.lauunem d.st_time d.oristime d.oristime2 d.oristime3 d.time d.time2 d.time3, vce(clus hp2histclus) nocons
reg d.lco2egen d.post_t d.hp2magXpt d.coald d.lnet_gen  d.lauunem d.st_time d.oristime d.oristime2 d.oristime3 d.time d.time2 d.time3, vce(clus hp2magclus) nocons
reg d.lco2egen d.post_t d.hentroXpt d.coald d.lnet_gen d.lauunem d.st_time d.oristime d.oristime2 d.oristime3 d.time d.time2 d.time3, vce(clus hentroclus) nocons

************************************************************
* Table 1. Descriptive statistics in power plant sample *
************************************************************
su lco2egen p2flag_t hp2hist_t hp2mag_t hentro_t coald lnet_gen lauunem if e(sample) 

******************************************************************************************************
* Appendix Table 3. Comparison between treatment and control groups by the measures of P2 experience.
******************************************************************************************************
sort p2flag_t
by p2flag_t: su net_gen co2e_gen lco2egen if e(sample)
by p2flag_t: tab coald if e(sample) 
sort hp2hist_t
by hp2hist_t: su net_gen co2e_gen lco2egen if e(sample)
by hp2hist_t: tab coald if e(sample)
sort hp2mag_t
by hp2mag_t: su net_gen co2e_gen lco2egen if e(sample)
by hp2mag_t: tab coald if e(sample) 
sort hentro_t
by hentro_t: su net_gen co2e_gen lco2egen if e(sample)
by hentro_t: tab coald if e(sample) 

*******************************************************************************************************************************
* Table 3. Revisiting the effects of P2 experience on GHG emissions with an event study design and fixed effects estimation
*******************************************************************************************************************************

xtset oris_code time
eventdd lco2egen  post_t coald  lnet_gen lauunem st_time oristime oristime2 oristime3 time time2 time3, fe timevar(ttt)  baseline(0) ci(rarea) graph_op(scheme(s1mono) ytitle("% change in GHG emission rate")) ci_op(fcolor(ltlue%5))
eventdd lco2egen  post_t coald  lnet_gen lauunem st_time oristime oristime2 oristime3 time time2 time3, fe timevar(ttth) baseline(0)ci(rarea) graph_op(scheme(s1mono) ytitle("% change in GHG emission rate")) ci_op(fcolor(ltlue%5))
eventdd lco2egen  post_t coald  lnet_gen lauunem st_time oristime oristime2 oristime3 time time2 time3, fe timevar(tttm) baseline(0)ci(rarea) graph_op(scheme(s1mono) ytitle("% change in GHG emission rate")) ci_op(fcolor(ltlue%5))
eventdd lco2egen  post_t coald  lnet_gen lauunem st_time oristime oristime2 oristime3 time time2 time3, fe timevar(ttte) baseline(0)ci(rarea) graph_op(scheme(s1mono) ytitle("% change in GHG emission rate")) ci_op(fcolor(ltlue%5))

*****************************************************************************************************************************************************
* Appendix Table 1. Fixed Effects Estimation on the Effects of P2 Experience on the Levels of GHG Emissions with State-by-year Interactions
*****************************************************************************************************************************************************
xtset oris_code time
reghdfe lco2egen post_t p2flagXpt coald lnet_gen lauunem, absorb(c.oris_code##i.year c.st_fips#i.year) vce(clus p2flagclus) 
reghdfe lco2egen post_t hp2histXpt coald lnet_gen lauunem, absorb(c.oris_code##i.year c.st_fips#i.year) vce(clus hp2histclus) 
reghdfe lco2egen post_t hp2magXpt coald lnet_gen lauunem, absorb(c.oris_code##i.year c.st_fips#i.year)  vce(clus hp2magclus) 
reghdfe lco2egen post_t hentroXpt coald lnet_gen lauunem, absorb(c.oris_code##i.year c.st_fips#i.year) vce(clus hentroclus) 

******************************************************************************
* Appendix Table 2. Time placebo test (assuming GHGRP started in 2007).
******************************************************************************

xtset oris_code time 
reg d.lco2egen d.post_t d.p2flagXplac d.coald  d.lnet_gen d.lauunem d.st_time d.oristime d.oristime2 d.oristime3 d.time d.time2 d.time3, vce(clus p2flagclus_plac) nocons
reg d.lco2egen d.post_t d.hp2histXplac d.coald d.lnet_gen d.lauunem d.st_time d.oristime d.oristime2 d.oristime3 d.time d.time2 d.time3, vce(clus hp2histclus_plac) nocons
reg d.lco2egen d.post_t d.hp2magXplac d.coald d.lnet_gen  d.lauunem d.st_time d.oristime d.oristime2 d.oristime3 d.time d.time2 d.time3, vce(clus hp2magclus_plac) nocons
reg d.lco2egen d.post_t d.hentropyXplac d.coald d.lnet_gen d.lauunem d.st_time d.oristime d.oristime2 d.oristime3 d.time d.time2 d.time3, vce(clus hentroclus_plac) nocons

 
******************************************************************************
*Figure 1. Average log of GHG emission by treatment and control plants.
******************************************************************************

sort p2flag_t year
by p2flag_t year: su lco2egen
sort hp2hist_t year
by hp2hist_t year: su lco2egen 
sort hp2mag_t year
by hp2mag_t year: su lco2egen
sort hentro_t year
by hentro_t year: su lco2egen 




